package com.orange.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class VoiceMailUtils {
	private static final String	TAG				= "VoiceMailUtils";

	private static final String	KEY_DATE		= "date";
	private static final String	KEY_FROMNUMBER	= "fromNumber";

	private static final String	VVM_PKG_NAME	= "com.orange.vvm";
	private static final String	VVM_CLS_NAME	= "com.orange.vvm.activity.Welcome";

	// if Voice Mail
	public static void startVoiceMailActivity(Context context) throws Exception {
		startVoiceMailActivityByNtfc(context);
	}

	private static void startVoiceMailActivityByNtfc(Context context) {
		Intent intent = new Intent();
		try {
			ComponentName cn = new ComponentName(VVM_PKG_NAME, VVM_CLS_NAME);
			intent.setComponent(cn);
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			LSServiceUtils.startActivity(context, intent);
		} catch (ActivityNotFoundException ex) {
			LogHelper.e(TAG, "startVoiceMailActivityByNtfc. ", ex);
		}
	}

	public static List<String> getNumbersByResult(Context context,
			List<Map<String, String>> resultList) {
		List<String> ret = new ArrayList<String>();
		for (int count = 0; count < resultList.size(); count++) {
			Map<String, String> tempMap = resultList.get(count);
			ret.add(tempMap.get(KEY_FROMNUMBER));
			LogHelper.e(TAG,
					"getNumbersByResult. date: " + tempMap.get(KEY_DATE)
							+ " ,fromNumber: " + tempMap.get(KEY_FROMNUMBER));
		}
		return ret;
	}
}
